package org.crazyit.cloud;

import org.crazyit.cloud.MyConfig.Person;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
@RestController
public class BookApplication {

	@Autowired
	private Environment env;

	@RequestMapping("/")
	public String home() {
		System.out.println("读取的值：" + env.getProperty("test.user.name"));
		return "Hello";
	}

	@Autowired
	private Person person;

	@RequestMapping("/person")
	public String getPerson() {
		System.out.println("输出 Person 实例：" + person + ", 名字："
				+ person.getName());
		return "Hello";
	}

	public static void main(String[] args) {
		new SpringApplicationBuilder(BookApplication.class).web(true).run(args);
	}
}
